package com.it;

//static测试类
public class StaticDemo {
    public static void main(String[] args) {
        StaticVar staticVar1 = new StaticVar();
        staticVar1.show();

        StaticVar staticVar2 = new StaticVar();
        staticVar2.show();

        StaticVar staticVar3 = new StaticVar();
        staticVar3.show();

        System.out.println(StaticVar.b);//静态变量一般用类名.来访问

        StaticBlock staticBlock1 = new StaticBlock();
        StaticBlock staticBlock2 = new StaticBlock();
        StaticBlock staticBlock3 = new StaticBlock();
        /**
         * 静态块
         * 构造方法
         * 构造方法
         * 构造方法
         * 这里执行的结果为这个，因为静态块在类加载时执行，并且只执行一次
         */

        StaticMethod staticMethod = new StaticMethod();
        staticMethod.show();//直接对象访问执行方法
        StaticMethod.test();//直接类名访问执行方法



    }
}
